import math

# 142857 与 1~10 相乘
# num = 142857
# mulNums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# for one in mulNums:
#     print(str(num) + "*" + str(one) + ":" + str(num * one))

# 1到10: 分之一 求解
# print("------")
# for one in range(1,10):
#     print(str(one) + ":" + str(round(1 / one, 12)))

# 7 分之一 的结果
# print("------")
# oneNums = [1, 2, 3, 4, 5, 6, 7]
# for one in oneNums:
#     print(str(one) + ":" + str(round(one / 7, 12)))
# print("------")

print("~~~")
print("阶乘结果所有位数字相加")
def Factorial(num):
    a = 1
    for one in range(1, num + 1):
        a = a * one
    return a
def NumAdd(num):
    sum = 0
    while num != 0:
        n = num % 10
        sum += n 
        num = num // 10
    return sum
for one in range(1, 100):
    calcNum = Factorial(one)
    sumNum = NumAdd(calcNum)
    while (sumNum // 10 != 0):
        sumNum = NumAdd(sumNum)
    print(str(one) + "!" +
        "=" + str(calcNum) + 
        "=>" + str(NumAdd(sumNum)))
print("~~~")

